package com.onlineclass.userserver.controller;

import com.onlineclass.userserver.service.IUserService;
import com.onlineclassbackstage.beans.ResultObject;
import com.onlineclassbackstage.beans.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
public class LoginController {

    @Autowired
    IUserService service;

    @RequestMapping("/login")
    public User loginByUser(String username,String rolename,HttpSession session){
        User user = service.login(username, rolename);
//        session.setAttribute("user",user);
//        System.out.println(session.getAttributeNames().toString());
//        System.out.println(session.getId());
//        System.out.println(session.getAttribute("user"));
        return user;

    }

    @RequestMapping("/test")
    public String test(){
        return "sdfghgfd";
    }

}
